import request from '@/config/axios'
import {PatDetailsVO} from "@/api/ecg/common";

// 装机拆机 VO
export interface DevRentVO {
  id: number | undefined // id
  applyNo: string | undefined // 预约申请号
  episodeId: string | undefined // 就诊流水号
  devId: string | undefined // 设备编号
  patId: string | undefined// 患者编号
  patName: string | undefined // 患者名称
  patDetails: PatDetailsVO | undefined
  checkType: number | undefined
  rentTime: Date | undefined // 装机时间
  returnTime: Date | undefined // 拆机时间
  interference: number | undefined // 干扰数
  baseline: string | undefined // 基线粗
  detachment: string | undefined // 脱落
  remark: string | undefined // 备注
  paid: number | undefined
  roomId: number | undefined
  bedNo: string | undefined
}

// 装机拆机 API
export const DevRentApi = {
  // 查询装机拆机分页
  getDevRentPage: async (params: any) => {
    return await request.get({ url: `/ecg/dev-rent/page`, params })
  },

  // 查询装机拆机详情
  getDevRent: async (id: number) => {
    return await request.get({ url: `/ecg/dev-rent/get?id=` + id })
  },

  // 新增装机拆机
  createDevRent: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/create`, data })
  },

  // 修改装机拆机
  updateDevRent: async (data: DevRentVO) => {
    return await request.put({ url: `/ecg/dev-rent/update`, data })
  },

  // 删除装机拆机
  deleteDevRent: async (id: number) => {
    return await request.delete({ url: `/ecg/dev-rent/delete?id=` + id })
  },

  // 导出装机拆机 Excel
  exportDevRent: async (params) => {
    return await request.download({ url: `/ecg/dev-rent/export-excel`, params })
  },

  // 根据患者或设备, 获取 Free的租赁
  getFreeRent: async (params: any) => {
    return await request.get({ url: `/ecg/dev-rent/get-free-rent`, params })
  },

  // 获取已领取的租赁
  getReadyRent: async (params: any) => {
    return await request.get({ url: `/ecg/dev-rent/get-ready-rent`, params })
  },

  // 获取已安装的租赁
  getInstalledRent: async (params: any) => {
    return await request.get({ url: `/ecg/dev-rent/get-installed-rent`, params })
  },

  // 获取已拆卸租赁
  getDismantledRent: async (params: any) => {
    return await request.get({ url: `/ecg/dev-rent/get-dismantled-rent`, params })
  },

  // 常规检查完成
  routineFinish: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/routine-finish`, data })
  },

  // 设备准备
  devReady: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-ready`, data })
  },

  // 装机
  devInstall: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-install`, data })
  },

  // 拆机
  devDismantle: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-dismantle`, data })
  },

  // 数据录入
  devDataEntry: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-data-entry`, data })
  },

  // 放弃..常规检查
  routineCheckCancel: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/routine-check-cancel`, data })
  },

  // 放弃领用
  devReadyCancel: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-ready-cancel`, data })
  },

  // 放弃装机
  devInstallCancel: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-install-cancel`, data })
  },

  // 遗失
  devLose: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-lose`, data })
  },

  // 损毁
  devDamage: async (data: DevRentVO) => {
    return await request.post({ url: `/ecg/dev-rent/dev-damage`, data })
  },

  // 确费
  feeConfirm: async (rentId: number) => {
    return await request.get({ url: `/ecg/dev-rent/fee-confirm?rentId=` + rentId })
  },

  // 取消确费
  feeCancel: async (rentId: number) => {
    return await request.get({ url: `/ecg/dev-rent/fee-cancel?rentId=` + rentId })
  },

}

